<template>
  <transition name="transverse-fade">
    <div v-show="visible" :class="['loading', position, theme]" :style="{zIndex}">
      <div class="loading-box">
        <span v-if="icon" :class="icon" />
        <span>{{ text }}</span>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'Loading',
  data () {
    return {
      theme: 'white',
      position: 'top',
      visible: false,
      text: '加载中...',
      zIndex: 199305,
      duration: 3000,
      infinity: false,
      icon: 'el-icon-loading'
    }
  }
}
</script>

<style lang="scss" scoped>
.loading {
  $borderRadius: 6px;
  position: fixed;
  left: 50%;
  font-size: 1.1rem;
  color: #333;
  background-color: #fff;
  border-radius: $borderRadius;
  &.white {
    background-color: #fff;
    color: #222;
  }
  &.dark {
    background-color: #222;
    color: #fff;
  }
  &.top {
    top: 1rem;
    transform: translate(-50%, 0);
  }
  &.middle {
    top: 50%;
    transform: translate(-50%, -50%);
  }
  &.bottom {
    bottom: 1rem;
    transform: translate(-50%, 0);
  }
  &-box {
    display: flex;
    align-items: center;
    padding: 15px;
    box-shadow: 0 2px 12px 0 rgba(148, 149, 160, 0.2);
    border-radius: $borderRadius;
    span + span {
      margin-left: 5px;
    }
  }
}
</style>
